#pragma once

class Light {
private:

	/* 	
		0 - enable 
		1 - constantAttenuation
		2 - linearAttenuation
		3 - quadraticAttenuation
	*/
	float param1[4] = {1,1,0,0}; 
	
	/* 	
		0..2 - position xyz
		3 - specular
	*/
	float param2[4] = {0,0,0,1};
	
	/* 	
		0..2 - diffuse rgb
		3 - radius
		
		если радиус менее нуля то радиусы не считаются
	*/
	float param3[4] = {1,1,1,-1};
	
	/*
		0 - inner radius
		1 - 1.0f / (radius - innerRadius)
		2..3 - unused
	*/	
	float param4[4] = {0,1,0,0};
	
public:

	void setInnerRadius(float value){
		param4[0] = value;
		param4[1] = (value >= param3[3])?1:1.0f / (param3[3] - param4[0]);
	}
	
	const float getInnerRadius() const{
		return param4[0];
	}

	void setRadius(float value){
		param3[3] = value;
		param4[1] = (value <= param4[1])?1:1.0f / (param3[3] - param4[0]);
	}
	
	const float getRadius() const{
		return param3[3];
	}

	void setQuadraticAttenuation(const float attenuation){
		param1[3] = attenuation;
	}
	
	void setConstantAttenuation(const float attenuation){
		param1[1] = attenuation;
	}

	void setLinearAttenuation(const float attenuation){
		param1[2] = attenuation;
	}

	const float getQuadraticAttenuation() const{
		return param1[3];
	}
	
	const float getConstantAttenuation() const{
		return param1[1];
	}

	const float getLinearAttenuation() const{
		return param1[2];
	}

	void setDiffuse(const glm::vec3& diffuse){
		param3[0] = diffuse.r;
		param3[1] = diffuse.g;
		param3[2] = diffuse.b;
	}

	const glm::vec3 getDiffuse() const {
		return glm::vec3(param3[0],param3[1],param3[2]);
	}

	void enable(){
		param1[0] = 1.0f;
	}
	
	void disable(){
		param1[0] = 0.0f;
	}
	
	const bool isEnable() const {
		return param1[0]!=0;
	}

	const glm::vec3 getPosition() const{
		return glm::vec3(param2[0],param2[1],param2[2]);
	}
	
	void setPosition(const glm::vec3& position){
		param2[0]  = position.x;
		param2[1]  = position.y;
		param2[2]  = position.z;
	}
	
	const float getSpecular() const{
		return param2[3];
	}
	
	void setSpecular(const float specular){
		param2[3] = specular;
	}
	
};


